package com.jiang.jixiang.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.jiang.jixiang.R;
import com.ws.universal.tools.headimgview.CircleImageView;
import com.ws.universal.tools.utils.glide.GlideUtils;

public class MalfunctionUploadAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    public MalfunctionUploadAdapter() {
        super(R.layout.item_malfunctionupload);
        addChildClickViewIds(R.id.imgItemAdd);
        addChildClickViewIds(R.id.imgItemClose);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, String bean) {
        RelativeLayout rlLayout = holder.findView(R.id.rlLayout);
        CircleImageView imgItemAdd = holder.findView(R.id.imgItemAdd);
        ImageView imgItemClose = holder.findView(R.id.imgItemClose);
        if (getItemPosition(bean) == getData().size() - 1) {
            imgItemClose.setVisibility(View.GONE);
            imgItemAdd.setImageResource(R.mipmap.icon_upload);
            if (getData().size() > 3) {
                rlLayout.setVisibility(View.GONE);
            } else {
                rlLayout.setVisibility(View.VISIBLE);
            }
        } else {
            imgItemClose.setVisibility(View.VISIBLE);
            GlideUtils.CreateImageRound(bean, imgItemAdd);
        }


    }
}
